using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace TgcViewer.Utils.Modifiers
{
    /// <summary>
    /// Panel generico para un Modifier
    /// </summary>
    public abstract class TgcModifierPanel
    {
        protected FlowLayoutPanel mainPanel;
        public FlowLayoutPanel MainPanel
        {
            get { return mainPanel; }
        }

        protected Button showHideButton;
        protected FlowLayoutPanel contentPanel;
        TgcModifiers tgcModifiers;

        private string varName;
        public string VarName
        {
            get { return varName; }
        }


        public TgcModifierPanel(string varName)
        {
            this.varName = varName;

            mainPanel = new FlowLayoutPanel();
            mainPanel.Margin = new Padding(3);
            mainPanel.AutoSize = true;
            mainPanel.FlowDirection = FlowDirection.TopDown;
            mainPanel.BorderStyle = BorderStyle.Fixed3D;

            showHideButton = new Button();
            showHideButton.Margin = new Padding(0);
            showHideButton.Click += new EventHandler(showHideButton_click);
            showHideButton.AutoSize = true;
            showHideButton.Size = new Size(1, 1);
            showHideButton.Text = varName;

            contentPanel = new FlowLayoutPanel();
            contentPanel.Margin = new Padding(0);
            contentPanel.AutoSize = true;
            contentPanel.FlowDirection = FlowDirection.TopDown;
            contentPanel.Name = "contentPanel";

            mainPanel.Controls.Add(showHideButton);
            mainPanel.Controls.Add(contentPanel);
        }

        internal void setTgcModifiers(TgcModifiers tgcModifiers)
        {
            this.tgcModifiers = tgcModifiers;
        }

        private void showHideButton_click(object sender, EventArgs e)
        {
            contentPanel.Visible = !contentPanel.Visible;
            GuiController.Instance.focus3dPanel();
        }

        /// <summary>
        /// Devuelve el valor del variable del modificador.
        /// Se debe castear al tipo que corresponda.
        /// </summary>
        public abstract object getValue();

        protected void notifyChange()
        {
            tgcModifiers.variableChanged();
        }


    }
}
